/*
 * Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.huawei.csi.tool.domain.score;

import javafx.scene.control.TreeItem;

/**
 * 文档完备度 (20)
 *
 * @author lxw
 */
public class DocCompletenessScore extends AbstractScore {
    /**
     * 或更多的公共API有符合仓颉doc注释
     */
    private int commentsScore = 10;

    /**
     * 有使用示例
     */
    private int useExampleScore = 10;

    public DocCompletenessScore() {
        super.beforeScore = commentsScore + useExampleScore;
    }

    public int getCommentsScore() {
        return commentsScore;
    }

    public void setCommentsScore(int commentsScore) {
        this.commentsScore = commentsScore;
    }

    public int getUseExampleScore() {
        return useExampleScore;
    }

    public void setUseExampleScore(int useExampleScore) {
        this.useExampleScore = useExampleScore;
    }


    @Override
    public int beforeVerifyScore() {
        return super.beforeScore;
    }

    @Override
    public int afterVerifyScore() {
        return commentsScore + useExampleScore;
    }

    @Override
    @SuppressWarnings("all")
    public TreeItem<String> treeItem() {
        TreeItem<String> root = new TreeItem<>("文档完备度（" + afterVerifyScore() + "/" + beforeScore + ")");
        TreeItem<String> commentsTreeItem = new TreeItem<>(commentsScore + "/" + 10 + " 20%或更多的公共API有符合仓颉文档注释");
        TreeItem<String> useExampleTreeItem = new TreeItem<>(useExampleScore + "/" + 10 + " 有使用示例");
        root.getChildren().addAll(commentsTreeItem, useExampleTreeItem);
        return root;
    }
}
